<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/inc/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>授权角色给实体信息信息列表</title>
<%@ include file="/inc/head.jsp"%>
<script type="text/javascript">
	var grid;
	$(function() {
		grid = $('#grid')
				.datagrid(
						{
							title : '',
							url : '${ctx}/sys/auth?search.type_eq=user',
							striped : true,
							rownumbers : true,
							pagination : true,
							idField : 'id',
							sortName : 'createDate',
							sortOrder : 'desc',
							pageSize : 50,
							pageList : [ 10, 20, 30, 40, 50, 100, 200, 300,
									400, 500 ],
							frozenColumns : [ [ {
								width : '200',
								title : '用户名称',
								field : 'userId',
								sortable : true,
								fomatter : function(value) {
									return value;
								}
							}, {
								width : '300',
								title : '角色列表',
								field : 'roleIds',
								sortable : true
							} ] ],
							columns : [ [ {
								title : '操作',
								field : 'action',
								width : '90',
								formatter : function(value, row) {
									var str = '';
									str += sy
											.formatString(
													'<img class="iconImg ext-icon-note_edit" title="编辑" onclick="auth.edit(\'{0}\');"/>',
													row.id);
									str += sy
											.formatString(
													'<img class="iconImg ext-icon-note_delete" title="删除" onclick="auth.del(\'{0}\');"/>',
													row.id);
									return str;
								}
							} ] ],
							toolbar : '#toolbar',
							onBeforeLoad : function(param) {
								parent.$.messager.progress({
									text : '数据加载中....'
								});
							},
							onLoadSuccess : function(data) {
								$('.iconImg').attr('src', sy.pixel_0);
								parent.$.messager.progress('close');
							}
						});
		auth = {
			create : function() {
				var dialog = sy.modalDialog({
					title : '新增授权信息',
					url : sy.contextPath + '/sys/auth/user_group/create',
					buttons : [ {
						text : '保存',
						handler : function() {
							dialog.find('iframe').get(0).contentWindow
									.submitForm(dialog, grid, parent.$);
						}
					} ]
				});
			},
			createUser : function() {
				var dialog = sy.modalDialog({
					title : '新增授权信息',
					url : sy.contextPath + '/sys/auth/user/create',
					buttons : [ {
						text : '保存',
						handler : function() {
							dialog.find('iframe').get(0).contentWindow
									.submitForm(dialog, grid, parent.$);
						}
					} ]
				});
			},
			del : function(id) {
				parent.$.messager.confirm('询问', '您确定要删除此记录？', function(r) {
					var url = "${ctx}/sys/auth/" + id + "/delete";
					if (r) {
						$.post(url, function() {
							grid.datagrid('reload');
						}, 'json');
					}
				});
			},
			edit : function(id) {
				var url = "${ctx}/sys/auth/update/" + id;
				var dialog = sy.modalDialog({
					title : '编辑授权信息',
					url : url,
					buttons : [ {
						text : '修改',
						handler : function() {
							dialog.find('iframe').get(0).contentWindow
									.submitForm(dialog, grid, parent.$);
						}
					} ]
				});

			}
		};
	});
</script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
	<div id="toolbar" style="display: none;">
		<div>
			<a href="javascript:void(0);" class="easyui-linkbutton"
				data-options="iconCls:'ext-icon-note_add',plain:true"
				onclick="auth.create();">授权给用户组</a> <a href="javascript:void(0);"
				class="easyui-linkbutton"
				data-options="iconCls:'ext-icon-note_add',plain:true"
				onclick="auth.createUser();">授权给用户</a>
		</div>
	</div>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid" data-options="fit:true,border:false"></table>
	</div>
</body>
</html>